package org.loong.crypto.service.core.context;

import java.security.SecureRandom;

import org.loong.crypto.common.utils.SecureRandomHolder;

public class CryptoContext {

    /**
     * The secure random generator.
     */
    private SecureRandom random;

    /**
     * Instantiates a new crypto context.
     */
    public CryptoContext() {

    }

    /**
     * Instantiates a new crypto context.
     *
     * @param random the random
     */
    public CryptoContext(final SecureRandom random) {
        this.random = random;
    }

    /**
     * Gets the value of random.
     *
     * @return the value of random
     */
    public SecureRandom getRandom() {
        return random != null ? random : SecureRandomHolder.getRandom();
    }

    /**
     * Sets the random.
     *
     * @param random the random to set
     */
    public void setRandom(final SecureRandom random) {
        this.random = random;
    }
}
